﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;

namespace EncryptStudy
{
    class Program
    {
        static void Main(string[] args)
        {
            string originalValue = "qingdao";
            Console.WriteLine("以下测试散列加密算法");
            string hashedValue = Cryptographer.CreateHash("MD5Cng", originalValue);
            Console.WriteLine("散列后的信息为{0}",hashedValue);
            bool isSuccessful = Cryptographer.CompareHash("MD5Cng", originalValue, hashedValue);
            if (isSuccessful == true)
            {
                Console.WriteLine("OK");
            }
            else
            {
                Console.WriteLine("Error");
            }

            Console.WriteLine("以下测试可逆加密算法");
            string encryptedValue= Cryptographer.EncryptSymmetric("DPAPI Symmetric Crypto Provider", originalValue);
            string decryptedValue = Cryptographer.DecryptSymmetric("DPAPI Symmetric Crypto Provider",encryptedValue);
            Console.WriteLine("原内容为{0}，加密后为{1}",originalValue,encryptedValue);
            Console.WriteLine("解密后为{0}",decryptedValue);

            Console.ReadLine();
        }
    }
}
